﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mogre;

namespace WastedMechanics.CharState
{
    public abstract class CharStateWalk : CharState
    {
        protected string AnimationName;

        public CharStateWalk(Character chr, string animName)
            : base(chr)
        {
            AnimationName = animName;
        }

        public override void Enter()
        {
            Character.SetAnimation(AnimationName);
            Character.CanTurn = true;
            Character.IsMoving = true;
        }

        public override void Exit()
        {
            Character.IsMoving = false;
        }

        public override void HaltOrder()
        {
            Character.SwitchState(GetIdleState());
        }  

        public override void Update()
        {
            Character.Velocity = Character.Orientation * Vector3.UNIT_Z * Character.Profile.WalkSpeed;

            if (!Character.IsOnGround || Character.Body.Velocity.y < -3)
                Character.SwitchState(GetFallingState());
        }

        public abstract CharState GetIdleState();
        public abstract CharState GetFallingState();
    }
}
